<?php
/**@var \Weline\Framework\View\Template $this */
/**@var \Weline\Backend\Block\ThemeConfig $themeConfig */
$themeConfig = \Weline\Framework\Manager\ObjectManager::getInstance(\Weline\Backend\Block\ThemeConfig::class);
?>
<!DOCTYPE html>
<!--
 *@Author       秋枫雁飞
 *@Email        aiweline@qq.com
 *@Forum        https://bbs.aiweline.com
 *@DESC         后台共用头部
-->
<html lang='en' <?= ('rtl' === $themeConfig->getThemeModel()) ? " dir=\"rtl\"" : '' ?>>
<head>
    <title><lang>管理员用户角色归属分配</lang></title>
    @template(Weline_Admin::common/head.phtml)
</head>

<body <?= $themeConfig->getLayouts() ?? ''; ?>>

<!--页头工具条 开始-->
@template(Weline_Admin::common/page/loading.phtml)
<!--页头工具条 结束-->

<!-- <body data-layout="horizontal" data-topbar="dark"> -->

<!-- 开始 页面 -->
<div id="layout-wrapper">

    <!--页头工具条 开始-->
    <w:block class='Weline\Admin\Block\Backend\Page\Topbar'/>
    <!--页头工具条 结束-->

    <!-- ========== Topnav Start ========== -->
    <!--页头菜单栏 开始-->
    <w:block class='Weline\Admin\Block\Backend\Page\Topnav'/>
    <!--页头菜单栏 结束-->

    <!-- ========== Left Sidebar Start ========== -->
    <!--左侧菜单栏 开始-->
    @template(Weline_Admin::common/left-sidebar.phtml)
    <!--左侧菜单栏 结束-->

    <!-- ============================================================== -->
    <!-- Start right Content here -->
    <!-- ============================================================== -->
    <div class="main-content">
        <div class='page-content'>
            <div class='container-fluid'>

                <!-- start page title -->
                <div class='row'>
                    <div class='col-12'>
                        <div class='page-title-box d-sm-flex align-items-center justify-content-between'>
                            <h4 class='mb-sm-0'>
                                <lang>管理员用户角色归属分配</lang>
                            </h4>
                            <div class='page-title-right'>
                                <ol class='breadcrumb m-0'>
                                    <li class='breadcrumb-item'>
                                        <a href='javascript: void(0);'>
                                            <lang>系统</lang>
                                        </a>
                                    </li>
                                    <li class='breadcrumb-item'>
                                        <a href="@backend-url('*/backend/user/listing')">
                                            <lang>管理员</lang>
                                        </a>
                                    </li>
                                    <li class='breadcrumb-item active'>
                                        <lang>管理员角色分配</lang>
                                    </li>
                                </ol>
                            </div>

                        </div>
                    </div>
                </div>
                <!-- end page title -->
                <!-- start page message -->
                <div class='row'>
                    <template>Weline_Component::message.phtml</template>
                </div> <!-- end message -->
                <div class='row'>
                    <div class='col-12'>
                        <div class='card'>
                            <div class='card-body'>

                                <h4 class='card-title'>
                                    <lang>管理员角色分配</lang>
                                </h4>
                                <p class='card-title-desc'>
                                    <lang>调整管理员角色</lang>
                                </p>
                                <div class='row'>
                                    <div class='col-6'>
                                        <div class='col-md-6'>
                                            <block class='Weline\Component\Block\Form\Search' id='admin-user-search'
                                                   action='*/backend/user'
                                                   method='get'
                                                   keyword='search' value=''
                                                   params=''
                                                   placeholder='请输入搜索词'></block>
                                        </div>
                                    </div>
                                    <div class='col-6'>
                                        <a class='btn btn-primary pull-right mt-1 mb-1' href="@backend-url('*/backend/user/listing')">
                                            <lang>返回</lang>
                                        </a>
                                    </div>
                                </div>

                                <div class='table-rep-plugin'>
                                    <div class='table-responsive mb-0' data-pattern='priority-columns'>
                                        <table id='tech-companies-1' class='table table-striped table-bordered'>
                                            <thead>
                                            <tr>
                                                <th data-priority='1'>
                                                    <lang>ID</lang>
                                                </th>
                                                <th data-priority='1'>
                                                    <lang>管理员</lang>
                                                </th>
                                                <th data-priority='1'>
                                                    <lang>邮箱</lang>
                                                </th>
                                                <th data-priority='1'>
                                                    <lang>角色分配</lang>
                                                </th>
                                                <th data-priority='1'>
                                                    <lang>创建于</lang>
                                                </th>
                                                <th data-priority='1'>
                                                    <lang>更新于</lang>
                                                </th>
                                                <th data-priority='1'>
                                                    <lang>操作</lang>
                                                </th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <foreach name='users' item='user' key='key'>
                                                <form action="@backend-url('*/backend/user/assignrole')" method="post">
                                                    <tr>
                                                        <td class='co-name'>{{user.user_id}}</td>
                                                        <td class='co-name'>{{user.username}}</td>
                                                        <td class='co-name'>{{user.email}}</td>
                                                        <td class='co-name'>
                                                            <input type="hidden" name="user_id" value="{{user.user_id}}">
                                                            <select class="form-control" name="role_id" id="role_id">
                                                                <option selected><lang>未分配角色</lang></option>
                                                                <foreach name='roles' item='role'>
                                                                    <if condition="user.role_id === role.role_id">
                                                                        <option selected value='{{role.role_id}}'>{{role.role_name}}</option>
                                                                        <else/>
                                                                        <option value='{{role.role_id}}'>{{role.role_name}}</option>
                                                                    </if>
                                                                </foreach>
                                                            </select>
                                                        </td>
                                                        <td class='co-name'>{{user.create_time}}</td>
                                                        <td class='co-name'>{{user.update_time}}</td>
                                                        <td class='co-name'>
                                                            <if condition='user.user_id !== current_user.user_id'>
                                                                <div class='d-grid gap-2 d-md-flex'>
                                                                    <input type="submit" class="btn btn-primary" value="@lang{分配}">
                                                                </div>
                                                            </if>
                                                        </td>
                                                    </tr>
                                                </form>
                                            </foreach>
                                            <empty name='users'>
                                                <tr>
                                                    <td colspan='5' class='text-center'>
                                                        <lang>暂无记录</lang>
                                                    </td>
                                                </tr>
                                            </empty>
                                            </tbody>
                                        </table>
                                        {{pagination}}
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div> <!-- end col -->
                </div> <!-- end row -->
            </div> <!-- container-fluid -->
        </div>
        <!-- End Page-content -->

        <footer class="footer">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-sm-6">
                        <script>document.write(new Date().getFullYear())</script>
                        © Weline.
                    </div>
                    <div class="col-sm-6">
                        <div class="text-sm-end d-none d-sm-block">
                            Crafted with <i class="mdi mdi-heart text-danger"></i> By <a
                                    href="https://www.aiweline.com/">秋枫雁飞(aiweline)</a>
                        </div>
                    </div>
                </div>
            </div>
        </footer>

    </div>
    <!-- end main content-->

</div>
<!-- END layout-wrapper -->
<!--右边栏-->
@template(Weline_Admin::common/right-sidebar.phtml)

<!-- Table Editable plugin -->
<script src="@static(Weline_Admin::assets/libs/table-edits/build/table-edits.min.js)"></script>
<script src="@static(Weline_Admin::assets/js/pages/menus/table-editable.init.js)"></script>
<script src='@static(Weline_Admin::/libs/jquery.mCustomScrollbar/jquery.mCustomScrollbar.concat.min.js)'></script>
<!-- Responsive Table js -->
<script src='@static(Weline_Admin::assets/libs/admin-resources/rwd-table/rwd-table.min.js)'></script>

<!-- Init js -->
<script src='@static(Weline_Admin::assets/js/pages/table-responsive.init.js)'></script>
@template(Weline_Admin::common/footer.phtml)
</body>
</html>
